library_load <- suppressMessages(
list(
# Seurat
library(Seurat),
# SingleR
library(SingleR),
library(SingleCellExperiment),
# Data
library(tidyverse)
)
)
random_seed <- 42
set.seed(random_seed)
options(warn=-1)
# Set working directory to project root
setwd("/research/peer/fdeckert/FD20200109SPLENO")
# Source files
source("plotting_global.R")
source("bin/SeuratQC.R")
source("bin/plotDEA.R")
source("../scFacility/script/dirFacility.R")
# Plotting Theme
ggplot2::theme_set(theme_global_set()) # From project global source()
so_dir <- "data/object/adata_sct_hvg2000/"
so_file <- "data/object/so_sct_reg.rds"
so <- readRDS(so_file)
if(class(so)=="list") {
so <- merge(so[[1]], so[[2]])
}
meta <- read.csv(paste0(so_dir, "meta/meta.csv"), row.names=1)
umap <- read.csv(paste0(so_dir, "reductions/X_umap_paga/reduction.csv"), row.names=1, col.names=c("UMAP_1", "UMAP_2"))
so@meta.data <- meta
so[["X_umap"]] <- CreateDimReducObject(embeddings=as.matrix(umap), key="UMAP_", assay="RNA")
DefaultAssay(so) <- "RNA"
Idents(so) <- "leiden_res"
so$leiden_res <- factor(so$leiden_res, levels=c("0", "1", "2", "3,0", "3,1", "4", "5", "6", "7", "8", "9", "10", "11,0", "11,1", "11,2", "12", "13", "14", "15"))
# dplyr::group_by(so@meta.data, treatment, sample_rep, leiden_res) %>%
# dplyr::summarise(n=n()) %>%
# tidyr::spread(table, key=leiden_res, value=n) %>%
# knitr::kable("html") %>%
# as.character() %>%
# IRdisplay::display_html()
options(repr.plot.width=22.5, repr.plot.height=20)
dplot_1 <- dplot(so, reduction="X_umap", group_by="leiden_res", label=TRUE) + ggtitle("Leiden")
dplot_2 <- dplot(so, reduction="X_umap", group_by="tissue") + scale_color_manual(values=color$tissue) + ggtitle("Tissue")
dplot_3 <- dplot(so, reduction="X_umap", group_by="cc_phase_class") + scale_color_manual(values=color$cc_phase_class) + ggtitle("Cell cycle")
dplot_4 <- dplot(so, reduction="X_umap", group_by="label_fine_haemosphere") + scale_color_manual(values=color$label_fine_haemosphere) + ggtitle("Haemosphere label")
dplot_5 <- dplot(so, reduction="X_umap", group_by="sample_rep") + ggtitle("Replicate")
dplot_6 <- dplot(so, reduction="X_umap", group_by="treatment") + scale_color_manual(values=color$treatment) + ggtitle("Treatment")
fplot_1 <- fplot(so, reduction="X_umap", features="pMt_RNA") + ggtitle("Percentage Mt")
fplot_2 <- fplot(so, reduction="X_umap", features="pHb_RNA") + ggtitle("Percentage Hb")
fplot_3 <- fplot(so, reduction="X_umap", features="pRb_RNA") + ggtitle("Percentage Rb")
fplot_4 <- fplot(so, reduction="X_umap", features="nCount_RNA") + ggtitle("UMI count")
fplot_5 <- fplot(so, reduction="X_umap", features="nFeature_RNA") + ggtitle("Feature count")
dplot_comb <- dplot_1 + dplot_2 + dplot_3 + dplot_4 + dplot_5 + dplot_6 + fplot_1 + fplot_2 + fplot_3 + fplot_4 + fplot_5 + plot_layout(ncol=3)
dplot_comb
Marker genes are taken from Dahlin et al., 2018
so <- AddModuleScore(so, features=c("Procr"), name="msHSC") #Procr, Fgd5, Hoxb5
so <- AddModuleScore(so, features=c("Dntt"), name="msLy") #Dntt, Flt3, Rag2
so <- AddModuleScore(so, features=c("Cd3g", "Cd3e", "Cd3d", "Cd247"), name="msTly") #Dntt, Flt3, Rag2
so <- AddModuleScore(so, features=c("Igha"), name="msBly") #Dntt, Flt3, Rag2
so <- AddModuleScore(so, features=c("Pf4", "Itga2b", "Gp1bb"), name="msMeg") #Pf4, Itga2b, Gp1bb
so <- AddModuleScore(so, features=c("Klf1", "Epor", "Gata1"), name="msEry") #Klf1, Epor, Gata1
so <- AddModuleScore(so, features=c("Elane", "Gfi1", "Cebpe"), name="msNeu") #Elane, Gfi1, Cebpe
so <- AddModuleScore(so, features=c("Csf1r", "Ly86"), name="msMo") #Irgf8, Csf1r, Ly86
so <- AddModuleScore(so, features=c("Prg2", "Prg3"), name="msEo") #Prg2, Prg3
so <- AddModuleScore(so, features=c("Gzmb", "Cma1"), name="msMa") #Gzmb, Cma1
so <- AddModuleScore(so, features=c("Prss34", "Mcpt8"), name="msBa") #Prss34, Mcpt8
options(repr.plot.width=22.5, repr.plot.height=20)
fplot_1 <- fplot(so, reduction="X_umap", features="msHSC1") + ggtitle("HSC\n (Procr)") + theme(plot.title=element_text(hjust=0.5))
fplot_2 <- fplot(so, reduction="X_umap", features="msLy1") + ggtitle("Lymphoid\n (Dntt)") + theme(plot.title=element_text(hjust=0.5))
fplot_3 <- fplot(so, reduction="X_umap", features="msTly1") + ggtitle("T Lymphoid\n (Cd3, Cd247)") + theme(plot.title=element_text(hjust=0.5))
fplot_4 <- fplot(so, reduction="X_umap", features="msBly1") + ggtitle("B Lymphoid\n (Igha)") + theme(plot.title=element_text(hjust=0.5))
fplot_5 <- fplot(so, reduction="X_umap", features="msMeg1") + ggtitle("Megakaryocyte\n (Pf4, Itga2b, Gp1bb)") + theme(plot.title=element_text(hjust=0.5))
fplot_6 <- fplot(so, reduction="X_umap", features="msEry1") + ggtitle("Erythroid\n (Klf1, Epor, Gata1)") + theme(plot.title=element_text(hjust=0.5))
fplot_7 <- fplot(so, reduction="X_umap", features="msNeu1") + ggtitle("Neutrophil\n (Elane, Gfi1, Cebpe)") + theme(plot.title=element_text(hjust=0.5))
fplot_8 <- fplot(so, reduction="X_umap", features="msMo1") + ggtitle("Monocyte\n (Csf1r, Ly86)") + theme(plot.title=element_text(hjust=0.5))
fplot_9 <- fplot(so, reduction="X_umap", features="msEo1") + ggtitle("Eosinophil\n (Prg2, Prg3)") + theme(plot.title=element_text(hjust=0.5))
fplot_10 <- fplot(so, reduction="X_umap", features="msMa1") + ggtitle("Mast\n (Gzmb, Cma1)") + theme(plot.title=element_text(hjust=0.5))
fplot_11 <- fplot(so, reduction="X_umap", features="msBa1") + ggtitle("Basophil\n (Prss34, Mcpt8)") + theme(plot.title=element_text(hjust=0.5))
fplot_12 <- fplot(so, reduction="X_umap", features="Ms4a3") + ggtitle("GMP\n (Prss34, Mcpt8)") + theme(plot.title=element_text(hjust=0.5))
dplot_comb <- fplot_1 + fplot_2 + fplot_3 + fplot_4 + fplot_5 + fplot_6 + fplot_7 + fplot_8 + fplot_9 + fplot_10 + fplot_11 + fplot_12 + plot_layout(ncol=4)
dplot_comb
options(repr.plot.width=22.5, repr.plot.height=10)
fplot_1 <- fplot(so, reduction="X_umap", features="Gata2") + ggtitle("Gata2")
fplot_2 <- fplot(so, reduction="X_umap", features="Gata1") + ggtitle("Gata1")
fplot_3 <- fplot(so, reduction="X_umap", features="Epor") + ggtitle("Epor")
fplot_4 <- fplot(so, reduction="X_umap", features="Epop") + ggtitle("Epop")
fplot_4 <- fplot(so, reduction="X_umap", features="Tfrc") + ggtitle("Tfrc")
fplot_5 <- fplot(so, reduction="X_umap", features="Tfr2") + ggtitle("Tfr2")
fplot_6 <- fplot(so, reduction="X_umap", features="Icam4") + ggtitle("Icam4")
dplot_comb <- fplot_1 + fplot_2 + fplot_3 + fplot_4 + fplot_5 + fplot_6 + plot_layout(ncol=3)
dplot_comb
options(repr.plot.width=5, repr.plot.height=5)
so_ery <- subset(so, subset=leiden_res %in% c("3,0", "4", "1", "2", "0"))@meta.data
so_ery$leiden_res <- factor(so_ery$leiden_res, levels=c("3,0", "4", "1", "2", "0"))
so_ery$label_fine_haemosphere <- factor(so_ery$label_fine_haemosphere, levels=names(color$label_fine_haemosphere))
ggplot(so_ery, aes(x=leiden_res, fill=label_fine_haemosphere)) +
geom_bar() +
scale_fill_manual(values=color$label_fine_haemosphere[names(color$label_fine_haemosphere) %in% so_ery$label_fine_haemosphere]) +
guides(fill=guide_legend(ncol=2))
options(repr.plot.width=22.5, repr.plot.height=15)
fplot_1 <- fplot(so, reduction="X_umap", features="Cd8a") + ggtitle("Cd8a")
fplot_2 <- fplot(so, reduction="X_umap", features="Cd4") + ggtitle("Cd4")
fplot_3 <- fplot(so, reduction="X_umap", features="H2-Eb1") + ggtitle("H2-Eb1 (MHC II)")
fplot_4 <- fplot(so, reduction="X_umap", features="Ms4a3") + ggtitle("Ms4a3") # GMP
fplot_5 <- fplot(so, reduction="X_umap", features="Cx3cr1") + ggtitle("Cx3cr1") # Macrophage DC progenitor (MDP) derived
fplot_6 <- fplot(so, reduction="X_umap", features="Csf1r") + ggtitle("Csf1r") # Macrophage DC progenitor (MDP) derived
fplot_7 <- fplot(so, reduction="X_umap", features="Irf8") + ggtitle("Irf8") # Macrophage specification
fplot_8 <- fplot(so, reduction="X_umap", features="Nr1h3") + ggtitle("Nr1h3") # Macrophage specification
fplot_9 <- fplot(so, reduction="X_umap", features="Spic") + ggtitle("Spic") # Macrophage specification
fplot_10 <- fplot(so, reduction="X_umap", features="Sell") + ggtitle("CD62L") # Macrophage specification
dplot_comb <- fplot_1 + fplot_2 + fplot_3 + fplot_4 + fplot_5 + fplot_6 + fplot_7 + fplot_8 + fplot_9 + fplot_10 + plot_layout(ncol=4)
dplot_comb
options(repr.plot.width=22.5, repr.plot.height=5)
fplot_1 <- fplot(so, reduction="X_umap", features="Itgam") + ggtitle("Itgam (Cd11b)")
fplot_2 <- fplot(so, reduction="X_umap", features="Esam") + ggtitle("Esam") # DC subset
fplot_3 <- fplot(so, reduction="X_umap", features="Cst3") + ggtitle("Cst3")
fplot_4 <- fplot(so, reduction="X_umap", features="Ly6c2") + ggtitle("Ly6c2")
dplot_comb <- fplot_1 + fplot_2 + fplot_3 + fplot_4 + plot_layout(ncol=4)
dplot_comb
options(repr.plot.width=20, repr.plot.height=10)
fplot(so, reduction="X_umap", features=c("Adgre1", "Cd68", "Cd36", "Cd163", "Sirpa")) + plot_layout(ncol=4)
options(repr.plot.width=20, repr.plot.height=5)
fplot(so, reduction="X_umap", features=c("Adgre1", "Marco", "Cd209b", "Tnfrsf1a")) + plot_layout(ncol=4)
options(repr.plot.width=20, repr.plot.height=5)
fplot(so, reduction="X_umap", features=c("Adgre1", "Siglec1", "Tnfrsf1a")) + plot_layout(ncol=4)
# dea <- lapply(sort(unique(so$leiden_res)), function(leiden_res) {FindConservedMarkers(so, ident.1=leiden_res, grouping.var="treatment", assay="RNA", slot="data", test.use="wilcox")})
# saveRDS(dea, "result/annotation/dea_leiden_wilcox.rds")
# dea <- readRDS("result/annotation/dea_leiden_wilcox.rds")
# options(repr.plot.width=25, repr.plot.height=50)
# names(dea) <- paste("Cluster", 1:length(dea)-1)
# cmdp <- lapply(names(dea), function(title) {conserved_markers_dp(dea[[title]], title=title, n_top=50, filter="pos_only")})
# wrap_plots(cmdp, ncol=5)
dea <- lapply(sort(unique(so$leiden_res)), function(leiden_res) {FindConservedMarkers(so, ident.1=leiden_res, grouping.var="treatment", assay="RNA", slot="data", test.use="MAST")})
saveRDS(dea, "result/annotation/dea_leiden_mast.rds")
# dea <- readRDS("result/annotation/dea_leiden_mast.rds")
Testing group NaCl: (0) vs (5, 8, 10, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 4, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (0) vs (5, 10, 12, 7, 9, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 4, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (1) vs (5, 8, 10, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 4, 0, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (1) vs (5, 10, 12, 7, 9, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 4, 0, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (2) vs (5, 8, 10, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 4, 0, 1, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (2) vs (5, 10, 12, 7, 9, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 4, 0, 1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (3,0) vs (5, 8, 10, 9, 6, 7, 11,2, 11,1, 11,0, 14, 12, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (3,0) vs (5, 10, 12, 7, 9, 11,0, 6, 8, 15, 3,1, 11,2, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (3,1) vs (5, 8, 10, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 4, 0, 1, 2, 15) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (3,1) vs (5, 10, 12, 7, 9, 11,0, 6, 8, 3,0, 15, 11,2, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (4) vs (5, 8, 10, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (4) vs (5, 10, 12, 7, 9, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (5) vs (8, 10, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (5) vs (10, 12, 7, 9, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (6) vs (5, 8, 10, 9, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (6) vs (5, 10, 12, 7, 9, 11,0, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (7) vs (5, 8, 10, 9, 6, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (7) vs (5, 10, 12, 9, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (8) vs (5, 10, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (8) vs (5, 10, 12, 7, 9, 11,0, 6, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (9) vs (5, 8, 10, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (9) vs (5, 10, 12, 7, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (10) vs (5, 8, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (10) vs (5, 12, 7, 9, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (11,0) vs (5, 8, 10, 9, 6, 7, 3,0, 11,2, 11,1, 14, 12, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (11,0) vs (5, 10, 12, 7, 9, 6, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (11,1) vs (5, 8, 10, 9, 6, 7, 3,0, 11,2, 11,0, 14, 12, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (11,1) vs (5, 10, 12, 7, 9, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 13, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (11,2) vs (5, 8, 10, 9, 6, 7, 3,0, 11,1, 11,0, 14, 12, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (11,2) vs (5, 10, 12, 7, 9, 11,0, 6, 8, 3,0, 15, 3,1, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (12) vs (5, 8, 10, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (12) vs (5, 10, 7, 9, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (13) vs (5, 8, 10, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (13) vs (5, 10, 12, 7, 9, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (14) vs (5, 8, 10, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 12, 13, 4, 0, 1, 2, 15, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (14) vs (5, 10, 12, 7, 9, 11,0, 6, 8, 3,0, 15, 3,1, 11,2, 13, 11,1, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group NaCl: (15) vs (5, 8, 10, 9, 6, 7, 3,0, 11,2, 11,1, 11,0, 14, 12, 13, 4, 0, 1, 2, 3,1) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done! Testing group CpG: (15) vs (5, 10, 12, 7, 9, 11,0, 6, 8, 3,0, 3,1, 11,2, 13, 11,1, 14, 4, 0, 1, 2) Done! Combining coefficients and standard errors Calculating log-fold changes Calculating likelihood ratio tests Refitting on reduced model... Done!
# options(repr.plot.width=25, repr.plot.height=50)
# names(dea) <- paste("Cluster", 1:length(dea)-1)
# cmdp <- lapply(names(dea), function(title) {conserved_markers_dp(dea[[title]], title=title, n_top=50, filter="pos_only")})
# wrap_plots(cmdp, ncol=5)
# convert <- data.frame(
# leiden_res=c(
# "0",
# "1",
# "2",
# "3,0",
# "3,1",
# "4",
# "5",
# "6",
# "7",
# "8",
# "9",
# "10",
# "11,0",
# "11,1",
# "11,2",
# "12",
# "13",
# "14",
# "15"
# ),
# leiden_annotation=c(
# "Ery (4)",
# "Ery (2)",
# "Ery (3)",
# "MEP",
# "Meg",
# "Ery (1)",
# "MDP",
# "DC CD11b+ Esam+",
# "DC CD11b- CD8+",
# "MDP Ly6c-",
# "DC CD11b+ Ly6c+",
# "RPM",
# "GMP",
# "Baso",
# "Mo",
# "MPP",
# "DC CD11b- Esam+",
# "Plasma cell",
# "T lymphocyte"
# )
# )
# so@meta.data <- meta
# so[["X_umap"]] <- CreateDimReducObject(embeddings=as.matrix(umap), key="UMAP_", assay="RNA")
# annotation <- dplyr::left_join(so@meta.data, convert, by="leiden_res") %>%
# dplyr::mutate(cell_id=rownames(so@meta.data)) %>%
# tibble::column_to_rownames("cell_id") %>%
# dplyr::select(leiden_annotation)
# so <- AddMetaData(so, annotation)
# options(repr.plot.width=20, repr.plot.height=5)
# dplot_1 <- dplot(so, reduction="X_umap", group_by="leiden_res", label=TRUE) + ggtitle("Leiden")
# dplot_2 <- dplot(so, reduction="X_umap", group_by="leiden_annotation") + scale_color_manual(values=color$leiden_annotation) + ggtitle("Annotation")
# dplot_comb <- dplot_1 + dplot_2 + plot_layout(ncol=2)
# dplot_comb
# saveRDS(so, so_file)
# write.csv(so@meta.data, paste0(so_dir, "meta/meta.csv"))
# sessionInfo()